package com.bysj.yqsht.service.impl;

import com.bysj.yqsht.bean.CheckallTeacher;
import com.bysj.yqsht.bean.CheckallTeacherExample;
import com.bysj.yqsht.bean.extend.CheckallteacherExtend;
import com.bysj.yqsht.dao.CheckallTeacherMapper;
import com.bysj.yqsht.dao.extend.CheckallTeacherExtendMapper;
import com.bysj.yqsht.service.ICheckallTeacherService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ICheckallTeacherServiceImpl implements ICheckallTeacherService {
    @Resource
    private CheckallTeacherExtendMapper checkallTeacherExtendMapper;
    @Resource
    private CheckallTeacherMapper checkallTeacherMapper;
    @Override
    public List<CheckallTeacher> findAll() {
        CheckallTeacherExample example = new CheckallTeacherExample();
        return checkallTeacherMapper.selectByExample(example);
    }

    @Override
    public List<CheckallteacherExtend> findWithAll(int pageNum, int limit) {
        PageHelper.startPage(pageNum,limit);
        CheckallTeacherExample example = new CheckallTeacherExample();
        List<CheckallteacherExtend> list1 = checkallTeacherExtendMapper.findWithAll();
        PageInfo<CheckallteacherExtend> data = new PageInfo<CheckallteacherExtend>(list1);
        List<CheckallteacherExtend> list = data.getList();
        return list;
    }

    @Override
    public List<CheckallteacherExtend> findWithAllBy(Long studentId, Long classesId) {
        return checkallTeacherExtendMapper.findWithAllBy(studentId,classesId);
    }

    @Override
    public void saveOrUpdate(CheckallTeacher checkallTeacher) {
        if(checkallTeacher.getId() != null){
            checkallTeacherMapper.updateByPrimaryKey(checkallTeacher);
        } else {
            checkallTeacherMapper.insert(checkallTeacher);
        }
    }

    @Override
    public void deleteById(Long id) {
        checkallTeacherMapper.deleteByPrimaryKey(id);

    }
}
